// /utils/ble-store.js

import { reactive } from "vue";

// This simple reactive object will hold our device.
const store = reactive({
  activeDevice: null,
});

export const bleStore = {
  /**
   * Sets the globally active BluetoothDevice.
   * @param {BluetoothDevice} device The raw device object from the Web Bluetooth API.
   */
  setActiveDevice(device) {
    store.activeDevice = device;
  },

  /**
   * Retrieves the globally active BluetoothDevice.
   * @returns {BluetoothDevice | null}
   */
  getActiveDevice() {
    return store.activeDevice;
  },

  /**
   * Clears the active device from the store.
   */
  clearActiveDevice() {
    store.activeDevice = null;
  },
};
